<template>
	<view class="shopDetail-container">
		<scroll-view scroll-y="true" class="main">
			<swiper class="swiper" circular indicator-dots autoplay :interval="5000"
				indicator-active-color="#fff" :duration="500" v-if="detailInfo.images">
				<swiper-item v-for="item in detailInfo.images.split(',')" :key="item.src">
					<image style="width: 100%;height: 100%" :src="$fun.imgUrl(item)" mode=""></image>
				</swiper-item>
			</swiper>
			<view class="detail-main">
				<view class="price-box">
					<view class="price">
						<text>$</text>
						<text class="price-num">{{detailInfo.money}}</text>
					</view>
					<view class="browse">
						销量：{{detailInfo.num}}
					</view>
				</view>
				<view class="title">
					<text>{{detailInfo.name}}</text>
				</view>
				<view class="guarantee">
					<view class="left">
						保障
					</view>
					<view class="">
						严格查验 / 鉴别为真 / 假一赔三
					</view>
					<view class="" style="margin-left: 50rpx;">
						库存：{{detailInfo.stock}}
					</view>
				</view>
				<view class="" style="padding:30rpx;background-color: #fff;" >
					<view class="tabLists" v-if="detailInfo.contents">
						<view :class="tabIndex==index?'tabItem active':'tabItem' " @click="changeTab(index)"
							v-for="(item,index) in  tabList" :key="index">
							{{item.name}}
						</view>
					</view>
					<!-- <text style="font-size: 42rpx; font-weight: 600;">详情</text> -->
					<view class="" v-html="detailInfo.content" v-if="tabIndex==0"></view>
					<!-- <view class="" v-html="detailInfo.contents" v-else></view> -->
				</view>
			</view>
		</scroll-view>
		<view class="footer">
			<view class="">
				<u-button type="primary" color="#1e84f1" shape="circle"  :hairline="true" text="立即购买" @click="handleNext"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imageList: [],
				detailInfo:{},
				tabList:[{name:'商品详情'},{name:'上机教程'}],
				tabIndex: 0,
			};
		},
		onShow() {
			
		},
		// 分享好友
		onShareAppMessage() {
			return {
				title: '瓜瓜云',
				path: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		// 分享朋友圈
		onShareTimeline() {
			return {
				title: '瓜瓜云',
				query: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		async onLoad({ids}) {
			const res = await this.$fun.ajax.post('goods/getInfo', {ids:ids})
			if(res.code==1){
				this.detailInfo = res.data
			}
			
		},
		methods:{
			changeTab(index) {
				this.tabIndex = index
			},
			handleback(){
				this.$fun.jump('/pages/index/index')
			},
			handleNext(){
				this.$fun.jump(`/pageB/createOrder?id=${this.detailInfo.id}`)
			}
		}
	}
</script>

<style lang="scss">
	.shopDetail-container {
		padding-bottom: 100rpx;

		.detail-main {
			border-radius: 20rpx;

			.price-box {
				display: flex;
				justify-content: space-between;
				align-items: center;
				background-color: #fff;
				padding: 0rpx 15rpx;

				.price {
					font-size: 40rpx;
					color: #fa1418;

					.price-num {
						font-size: 64rpx;
						font-family: DIN, DIN;
						font-weight: bold;
						color: #fa1418;
					}

				}

				.browse {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #999999;

				}
			}

			.title {
				text {
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					color: #232323;
					overflow: hidden;
					-webkit-line-clamp: 2;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-box-orient: vertical;
				}

				padding: 10rpx 40rpx 30rpx;
				background-color: #fff;
			}

			.guarantee {
				height: 68rpx;
				background: #FFFFFF;
				border-radius: 24rpx 24rpx 24rpx 24rpx;
				opacity: 1;
				margin: 20rpx 30rpx;
				display: flex;
				align-items: center;
				font-size: 20rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				color: #232323;

				.left {
					border: 1px solid #1D93FF;
					margin: 0 30rpx;
					color: #1D93FF;
					padding: 5rpx 10rpx;
				}
			}

		}

		.footer {
			height: 100rpx;
			background: #FFFFFF;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;
			padding: 0 20rpx;
			

			.left {
				display: flex;
				align-items: center;

				.item-box {
					margin: 0 20rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;

					.icon {
						height: 35rpx;
					}

					.text {
						font-size: 20rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						color: #232323;
					}
				}
			}

			.right {
				color: #fff;
				font-weight: 600;
				font-size: 28rpx;
			}
		}
	}
</style>